#!/usr/bin/python
# Filename: ex_DSIntro_work_3_4.py

# Find the first char in string x which is not in y

# Analysis:
# if char in x and y are all common ASCII charactor,
# it's common to build a ASCII table to store char count of y.
# but if not, hash(dict) can be the only solution.

def find_first_incommon_char(s1, s2):
    '''return the first char in string s1 which is not in s2. if none, return None'''
    t = [0] * 128
    for i in s2:
        t[ord(i)] += 1
    for j in range(len(s1)):
        if t[ord(s1[j])] == 0:
            return (j, s1[j])
    return None

if __name__ == "__main__":
    s1 = "abcdefghijklmn"
    s2 = "nmlkjihgfedcba"
    print "find_first_incommon_char(%s, %s): %s" % (s1, s2, find_first_incommon_char(s1, s2))
    s1 = "abchij012"
    print "find_first_incommon_char(%s, %s): %s" % (s1, s2, find_first_incommon_char(s1, s2))
